package com.yueshop.cart.config;


import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;
import org.springframework.data.redis.serializer.RedisSerializer;
import org.springframework.session.web.http.CookieSerializer;
import org.springframework.session.web.http.DefaultCookieSerializer;

//springsession 设置子域整合 和 redis json序列化
@Configuration
public class YueShopSessionConfig {

    //设置 json序列化
    @Bean
    public RedisSerializer<Object> springSessionDefaultRedisSerializer() {
        return new GenericJackson2JsonRedisSerializer();
    }
    //设置cookie信息
    @Bean
    public CookieSerializer cookieSerializer() {
        DefaultCookieSerializer serializer = new DefaultCookieSerializer();
        //设置 session 存储的 作用域返回 不以.开头
        serializer.setDomainName("yueshop.com");
        //设置 session 名
        serializer.setCookieName("YUESHOPSESSION");
        return serializer;
    }


}
